<?xml version="1.0" encoding="ascii" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ascii" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>The Epytext Markup Language</title>
<link rel="stylesheet" href="custom.css" type="text/css" />
</head>
<body>
<div class="document" id="the-epytext-markup-language">
<h1 class="title">The Epytext Markup Language</h1>

<!-- $Id: manual-epytext.txt 1547 2007-02-21 17:34:54Z dvarrazzo $ -->
<div class="section" id="a-brief-introduction">
<h1>A Brief Introduction</h1>
<p>Epytext is a simple lightweight markup language that lets you add formatting
and structue to docstrings. Epydoc uses that formatting and structure to
produce nicely formatted API documentation. The following example (which has
an unusually high ratio of documentaiton to code) illustrates some of the
basic features of epytext:</p>
<pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">x_intercept</span>(m, b):
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    Return the x intercept of the line M{y=m*x+b}.  The X{x intercept}</span>
<span class="py-string">    of a line is the point at which it crosses the x axis (M{y=0}).</span>

<span class="py-string">    This function can be used in conjuction with L{z_transform} to</span>
<span class="py-string">    find an arbitrary function's zeros.</span>

<span class="py-string">    @type  m: number</span>
<span class="py-string">    @param m: The slope of the line.</span>
<span class="py-string">    @type  b: number</span>
<span class="py-string">    @param b: The y intercept of the line.  The X{y intercept} of a</span>
<span class="py-string">              line is the point at which it crosses the y axis (M{x=0}).</span>
<span class="py-string">    @rtype:   number</span>
<span class="py-string">    @return:  the x intercept of the line M{y=m*x+b}.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    return -b/m</pre>
<p>You can compare this function definition with the <a class="reference" href="http://epydoc.sourceforge.net/examples/epytext_example-module.html#x_intercept">API documentation</a>
generated by epydoc. Note that:</p>
<ul class="simple">
<li>Paragraphs are separated by blank lines.</li>
<li>Inline markup has the form &quot;<em>x</em><tt class="docutils literal"><span class="pre">{</span></tt>...<tt class="docutils literal"><span class="pre">}</span></tt>&quot;, where &quot;<em>x</em>&quot; is a
single capital letter. This example uses inline markup to mark mathematical
expressions (&quot;<tt class="docutils literal"><span class="pre">M{...}</span></tt>&quot;); terms that should be indexed (&quot;<tt class="docutils literal"><span class="pre">X{...}</span></tt>&quot;);
and links to the documentation of other objects (&quot;<tt class="docutils literal"><span class="pre">L{...}</span></tt>&quot;).</li>
<li>Descriptions of parameters, return values, and types are marked with
&quot;<tt class="docutils literal"><span class="pre">&#64;</span></tt><em>field</em><tt class="docutils literal"><span class="pre">:</span></tt>&quot; or &quot;<tt class="docutils literal"><span class="pre">&#64;</span></tt><em>field arg</em><tt class="docutils literal"><span class="pre">:</span></tt>&quot;, where &quot;<em>field</em>&quot;
identifies the kind of description, and &quot;<em>arg</em>&quot; specifies what object is
described.</li>
</ul>
<p>Epytext is intentionally very lightweight. If you wish to use a more
expressive markup language, I recommend <a class="reference" href="manual-othermarkup.html#restructuredtext">reStructuredText</a>.</p>
</div>
<div class="section" id="epytext-language-overview">
<h1>Epytext Language Overview</h1>
<p>Epytext is a lightweight markup language for Python docstrings. The epytext
markup language is used by epydoc to parse docstrings and create structured API
documentation. Epytext markup is broken up into the following categories:</p>
<ul>
<li><p class="first"><strong>Block Structure</strong> divides the docstring into nested blocks of text, such
as <em>paragraphs</em> and <em>lists</em>.</p>
<blockquote>
<p>o <strong>Basic Blocks</strong> are the basic unit of block structure.</p>
<p>o <strong>Hierarchical blocks</strong> represent the nesting structure of the docstring.</p>
</blockquote>
</li>
<li><p class="first"><strong>Inline Markup</strong> marks regions of text within a basic block with properties,
such as italics and hyperlinks.</p>
</li>
</ul>
</div>
<div class="section" id="block-structure">
<h1>Block Structure</h1>
<p>Block structure is encoded using indentation, blank lines, and a handful of
special character sequences.</p>
<ul class="simple">
<li>Indentation is used to encode the nesting structure of hierarchical blocks.
The indentation of a line is defined as the number of leading spaces on that
line; and the indentation of a block is typically the indentation of its
first line.</li>
<li>Blank lines are used to separate blocks. A blank line is a line that only
contains whitespace.</li>
<li>Special character sequences are used to mark the beginnings of some blocks.
For example, '<tt class="docutils literal"><span class="pre">-</span></tt>' is used as a bullet for unordered list items, and
'<tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span></tt>' is used to mark <a class="reference" href="manual-epytext.html#doctest-blocks">doctest blocks</a>.</li>
</ul>
<p>The following sections describe how to use each type of block structure.</p>
<div class="section" id="paragraphs">
<h2>Paragraphs</h2>
<p>A paragraph is the simplest type of basic block. It consists of one or more
lines of text. Paragraphs must be left justified (i.e., every line must have
the same indentation). The following example illustrates how paragraphs can be
used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This is a paragraph.  Paragraphs can</span>
<span class="py-string">    span multiple lines, and can contain</span>
<span class="py-string">    I{inline markup}.</span>

<span class="py-string">    This is another paragraph.  Paragraphs</span>
<span class="py-string">    are separated by blank lines.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    *[...]*</pre>
</td>
<td><p class="first">This is a paragraph. Paragraphs can span multiple lines,
and contain <em>inline markup</em>.</p>
<p class="last">This is another paragraph. Paragraphs are separated from each
other by blank lines.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="lists">
<h2>Lists</h2>
<p>Epytext supports both ordered and unordered lists. A list consists of one or
more consecutive <em>list items</em> of the same type (ordered or unordered), with the
same indentation. Each list item is marked by a <em>bullet</em>. The bullet for
unordered list items is a single dash character (<tt class="docutils literal"><span class="pre">-</span></tt>). Bullets for ordered
list items consist of a series of numbers followed by periods, such as
<tt class="docutils literal"><span class="pre">12.</span></tt> or <tt class="docutils literal"><span class="pre">1.2.8.</span></tt>.</p>
<p>List items typically consist of a bullet followed by a space and a single
paragraph. The paragraph may be indented more than the list item's bullet;
often, the paragraph is intended two or three characters, so that its left
margin lines up with the right side of the bullet. The following example
illustrates a simple ordered list.</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    1. This is an ordered list item.</span>

<span class="py-string">    2. This is a another ordered list</span>
<span class="py-string">    item.</span>

<span class="py-string">    3. This is a third list item.  Note that</span>
<span class="py-string">       the paragraph may be indented more</span>
<span class="py-string">       than the bullet.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    *[...]*</pre>
</td>
<td><ol class="first last arabic simple">
<li>This is an ordered list item.</li>
<li>This is another ordered list item.</li>
<li>This is a third list item. Note that the paragraph may be
indented more than the bullet.</li>
</ol>
</td>
</tr>
</tbody>
</table>
<p>List items can contain more than one paragraph; and they can also contain
sublists, <cite>literal blocks</cite>, and <cite>doctest blocks</cite>. All of the blocks contained
by a list item must all have equal indentation, and that indentation must be
greater than or equal to the indentation of the list item's bullet. If the
first contained block is a paragraph, it may appear on the same line as the
bullet, separated from the bullet by one or more spaces, as shown in the
previous example. All other block types must follow on separate lines.</p>
<p>Every list must be separated from surrounding blocks by indentation:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This is a paragraph.</span>
<span class="py-string">      1. This is a list item.</span>
<span class="py-string">      2. This a second list</span>
<span class="py-string">         item.</span>
<span class="py-string">           - This is a sublist</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    [...]</pre>
</td>
<td><p class="first">This is a paragraph.</p>
<ol class="last arabic simple">
<li>This is a list item.</li>
<li>This is a second list item.<ul>
<li>This is a sublist.</li>
</ul>
</li>
</ol>
</td>
</tr>
</tbody>
</table>
<p>Note that sublists must be separated from the blocks in their parent list
item by indentation. In particular, the following docstring generates an error,
since the sublist is not separated from the paragraph in its parent list item
by indentation:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    1. This is a list item.  Its</span>
<span class="py-string">    paragraph is indented 7 spaces.</span>
<span class="py-string">    - This is a sublist.  It is</span>
<span class="py-string">      indented 7 spaces.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><strong>L5: Error: Lists must be indented.</strong></td>
</tr>
</tbody>
</table>
<p>The following example illustrates how lists can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This is a paragraph.</span>
<span class="py-string">      1. This is a list item.</span>
<span class="py-string">        - This is a sublist.</span>
<span class="py-string">        - The sublist contains two</span>
<span class="py-string">          items.</span>
<span class="py-string">            - The second item of the</span>
<span class="py-string">              sublist has its own sublist.</span>

<span class="py-string">      2. This list item contains two</span>
<span class="py-string">         paragraphs and a doctest block.</span>

<span class="py-string">         &gt;&gt;&gt; print 'This is a doctest block'</span>
<span class="py-string">         This is a doctest block</span>

<span class="py-string">         This is the second paragraph.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">This is a paragraph.</p>
<ol class="last arabic">
<li><p class="first">This is a list item.</p>
<ul class="simple">
<li>This is a sublist.</li>
<li>The sublist contains two items.<ul>
<li>The second item of the sublist has its own own sublist.</li>
</ul>
</li>
</ul>
</li>
<li><p class="first">This list item contains two paragraphs and a doctest block.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> <span class="py-string">'This is a doctest block'</span>
<span class="py-output">This is a doctest block</span></pre>
<p>This is the second paragraph.</p>
</li>
</ol>
</td>
</tr>
</tbody>
</table>
<p>Epytext will treat any line that begins with a bullet as a list item. If you
want to include bullet-like text in a paragraph, then you must either ensure
that it is not at the beginning of the line, or use <a class="reference" href="manual-epytext.html#escaping">escaping</a> to prevent
epytext from treating it as markup:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This sentence ends with the number</span>
<span class="py-string">    1.  Epytext can't tell if the &quot;1.&quot;</span>
<span class="py-string">    is a bullet or part of the paragraph,</span>
<span class="py-string">    so it generates an error.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><strong>L4: Error: Lists must be indented.</strong></td>
</tr>
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This sentence ends with the number 1.</span>

<span class="py-string">    This sentence ends with the number</span>
<span class="py-string">    E{1}.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">This sentence ends with the number 1.</p>
<p class="last">This sentence ends with the number 1.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="sections">
<h2>Sections</h2>
<p>A section consists of a heading followed by one or more child blocks.</p>
<ul class="simple">
<li>The heading is a single underlined line of text. Top-level section headings
are underlined with the '<tt class="docutils literal"><span class="pre">=</span></tt>' character; subsection headings are
underlined with the '<tt class="docutils literal"><span class="pre">-</span></tt>' character; and subsubsection headings are
underlined with the '<tt class="docutils literal"><span class="pre">~</span></tt>' character. The length of the underline must
exactly match the length of the heading.</li>
<li>The child blocks can be paragraphs, lists, literal blocks, doctest blocks,
or sections. Each child must have equal indentation, and that indentation
must be greater than or equal to the heading's indentation.</li>
</ul>
<p>The following example illustrates how sections can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This paragraph is not in any section.</span>

<span class="py-string">    Section 1</span>
<span class="py-string">    =========</span>
<span class="py-string">      This is a paragraph in section 1.</span>

<span class="py-string">      Section 1.1</span>
<span class="py-string">      -----------</span>
<span class="py-string">      This is a paragraph in section 1.1.</span>

<span class="py-string">    Section 2</span>
<span class="py-string">    =========</span>
<span class="py-string">      This is a paragraph in section 2.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="h1 first">Section 1</p>
<p>This is a paragraph in section 1.</p>
<p class="h2">Section 1.1</p>
<p>This is a paragraph in section 1.1.</p>
<p class="h1">Section 2</p>
<p class="last">This is a paragraph in section 2.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="literal-blocks">
<h2>Literal Blocks</h2>
<p>Literal blocks are used to represent &quot;preformatted&quot; text. Everything within a
literal block should be displayed exactly as it appears in plaintext. In
particular:</p>
<ul class="simple">
<li>Spaces and newlines are preserved.</li>
<li>Text is shown in a monospaced font.</li>
<li>Inline markup is not detected.</li>
</ul>
<p>Literal blocks are introduced by paragraphs ending in the special sequence
&quot;<tt class="docutils literal"><span class="pre">::</span></tt>&quot;. Literal blocks end at the first line whose indentation is equal to
or less than that of the paragraph that introduces them. The following example
shows how literal blocks can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    The following is a literal block::</span>

<span class="py-string">        Literal /</span>
<span class="py-string">               / Block</span>

<span class="py-string">    This is a paragraph following the</span>
<span class="py-string">    literal block.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">The following is a literal block:</p>
<pre class="literal-block">
Literal /
       / Block
</pre>
<p class="last">This is a paragraph following the literal block.</p>
</td>
</tr>
</tbody>
</table>
<p>Literal blocks are indented relative to the paragraphs that introduce them;
for example, in the previous example, the word &quot;Literal&quot; is displayed with four
leading spaces, not eight. Also, note that the double colon (&quot;<tt class="docutils literal"><span class="pre">::</span></tt>&quot;) that
introduces the literal block is rendered as a single colon.</p>
</div>
<div class="section" id="doctest-blocks">
<h2>Doctest Blocks</h2>
<p>Doctest blocks contain examples consisting of Python expressions and their
output. Doctest blocks can be used by the doctest module to test the
documented object. Doctest blocks begin with the special sequence
&quot;<tt class="docutils literal"><span class="pre">&gt;&gt;&gt;</span></tt>&quot;. Doctest blocks are delimited from surrounding blocks by blank lines.
Doctest blocks may not contain blank lines. The following example shows how
doctest blocks can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    The following is a doctest block:</span>

<span class="py-string">        &gt;&gt;&gt; print (1+3,</span>
<span class="py-more">    </span><span class="py-string">    ...        3+5)</span>
<span class="py-string">        (4, 8)</span>
<span class="py-string">        &gt;&gt;&gt; 'a-b-c-d-e'.split('-')</span>
<span class="py-string">        ['a', 'b', 'c', 'd', 'e']</span>

<span class="py-string">    This is a paragraph following the</span>
<span class="py-string">    doctest block.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">The following is a doctest block:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> (1+3,
<span class="py-more">... </span>       3+5)
<span class="py-output">(4, 8)</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-string">'a-b-c-d-e'</span>.split(<span class="py-string">'-'</span>)
<span class="py-output">['a', 'b', 'c', 'd', 'e']</span></pre>
<p class="last">This is a paragraph following the doctest block.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="fields">
<h2>Fields</h2>
<p>Fields are used to describe specific properties of a documented object. For
example, fields can be used to define the parameters and return value of a
function; the instance variables of a class; and the author of a module. Each
field is marked by a <em>field tag</em>, which consist of an at sign ('<tt class="docutils literal"><span class="pre">&#64;</span></tt>')
followed by a <em>field name</em>, optionally followed by a space and a <em>field
argument</em>, followed by a colon ('<tt class="docutils literal"><span class="pre">:</span></tt>'). For example, '<tt class="docutils literal"><span class="pre">&#64;return:</span></tt>' and
'<tt class="docutils literal"><span class="pre">&#64;param</span> <span class="pre">x:</span></tt>' are field tags.</p>
<p>Fields can contain paragraphs, lists, literal blocks, and doctest blocks.
All of the blocks contained by a field must all have equal indentation, and
that indentation must be greater than or equal to the indentation of the
field's tag. If the first contained block is a paragraph, it may appear on the
same line as the field tag, separated from the field tag by one or more spaces.
All other block types must follow on separate lines.</p>
<p>Fields must be placed at the end of the docstring, after the description of
the object. Fields may be included in any order.</p>
<p>Fields do not need to be separated from other blocks by a blank line. Any line
that begins with a field tag followed by a space or newline is considered a
field.</p>
<p>The following example illustrates how fields can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    @param x: This is a description of</span>
<span class="py-string">        the parameter x to a function.</span>
<span class="py-string">        Note that the description is</span>
<span class="py-string">        indented four spaces.</span>
<span class="py-string">    @type x: This is a description of</span>
<span class="py-string">        x's type.</span>
<span class="py-string">    @return: This is a description of</span>
<span class="py-string">        the function's return value.</span>

<span class="py-string">        It contains two paragraphs.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><dl class="first last docutils">
<dt><strong>Parameters:</strong></dt>
<dd><p class="first"><strong>x</strong> - This is a description of the parameter x to a function.
Note that the description is indented four spaces.</p>
<blockquote class="last">
<em>(type=This is a description of x's type.)</em></blockquote>
</dd>
<dt><strong>Returns:</strong></dt>
<dd><p class="first">This is a description of the function's return value.</p>
<p class="last">It contains two paragraphs.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p>For a list of the fields that are supported by epydoc, see the <cite>epydoc fields</cite>
chapter.</p>
</div>
</div>
<div class="section" id="inline-markup">
<h1>Inline Markup</h1>
<p>Inline markup has the form '<tt class="docutils literal"><span class="pre">x{...}</span></tt>', where <tt class="docutils literal"><span class="pre">x</span></tt> is a single capital letter
that specifies how the text between the braces should be rendered. Inline
markup is recognized within paragraphs and section headings. It is <em>not</em>
recognized within literal and doctest blocks. Inline markup can contain
multiple words, and can span multiple lines. Inline markup may be nested.</p>
<p>A matching pair of curly braces is only interpreted as inline markup if the
left brace is immediately preceeded by a capital letter. So in most cases, you
can use curly braces in your text without any form of escaping. However, you do
need to escape curly braces when:</p>
<ol class="arabic simple">
<li>You want to include a single (un-matched) curly brace.</li>
<li>You want to preceed a matched pair of curly braces with a capital letter.</li>
</ol>
<p>Note that there is no valid Python expression where a pair of matched curly
braces is immediately preceeded by a capital letter (except within string
literals). In particular, you never need to escape braces when writing Python
dictionaries. See also <a class="reference" href="manual-epytext.html#escaping">escaping</a>.</p>
<div class="section" id="basic-inline-markup">
<h2>Basic Inline Markup</h2>
<blockquote>
Epytext defines four types of inline markup that specify how text should be
displayed:</blockquote>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">I{...}</span></tt>: Italicized text.</li>
<li><tt class="docutils literal"><span class="pre">B{...}</span></tt>: Bold-faced text.</li>
<li><tt class="docutils literal"><span class="pre">C{...}</span></tt>: Source code or a Python identifier.</li>
<li><tt class="docutils literal"><span class="pre">M{...}</span></tt>: A mathematical expression.</li>
</ul>
<p>By default, source code is rendered in a fixed width font; and mathematical
expressions are rendered in italics. But those defaults may be changed by
modifying the CSS stylesheet. The following example illustrates how the four
basic markup types can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    I{B{Inline markup} may be nested; and</span>
<span class="py-string">    it may span} multiple lines.</span>

<span class="py-string">      - I{Italicized text}</span>
<span class="py-string">      - B{Bold-faced text}</span>
<span class="py-string">      - C{Source code}</span>
<span class="py-string">      - M{Math}</span>

<span class="py-string">    Without the capital letter, matching</span>
<span class="py-string">    braces are not interpreted as markup:</span>
<span class="py-string">    C{my_dict={1:2, 3:4}}.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first"><strong>Inline markup</strong> <em>may be nested</em>; and it may span  multiple lines.</p>
<ul class="simple">
<li><em>Italicized text</em></li>
<li><strong>Bold-faced text</strong></li>
<li><tt class="docutils literal"><span class="pre">Source</span> <span class="pre">code</span></tt></li>
<li>Math: <em>m*x+b</em></li>
</ul>
<p class="last">Without the capital letter, matching braces are not interpreted as
markup: <tt class="docutils literal"><span class="pre">my_dict={1:2,</span> <span class="pre">3:4}</span></tt>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="urls">
<h2>URLs</h2>
<p>The inline markup construct <tt class="docutils literal"><span class="pre">U{</span></tt><em>text&lt;url&gt;</em><tt class="docutils literal"><span class="pre">}</span></tt> is used to create links
to external URLs and URIs. '<em>text</em>' is the text that should be displayed for
the link, and '<em>url</em>' is the target of the link. If you wish to use the URL as
the text for the link, you can simply write &quot;<tt class="docutils literal"><span class="pre">U{</span></tt><em>url</em><tt class="docutils literal"><span class="pre">}</span></tt>&quot;. Whitespace
within URL targets is ignored. In particular, URL targets may be split over
multiple lines. The following example illustrates how URLs can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    - U{www.python.org}</span>
<span class="py-string">    - U{http://www.python.org}</span>
<span class="py-string">    - U{The epydoc homepage&lt;http://</span>
<span class="py-string">    epydoc.sourceforge.net&gt;}</span>
<span class="py-string">    - U{The B{Python} homepage</span>
<span class="py-string">    &lt;www.python.org&gt;}</span>
<span class="py-string">    - U{Edward Loper&lt;mailto:edloper@</span>
<span class="py-string">    gradient.cis.upenn.edu&gt;}</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><ul class="first last simple">
<li><a class="reference" href="http://www.python.org">www.python.org</a></li>
<li><a class="reference" href="http://www.python.org">http://www.python.org</a></li>
<li><a class="reference" href="http://epydoc.sourceforge.net">The epydoc homepage</a></li>
<li><a class="reference" href="http://www.python.org">The <strong>Python</strong> homepage</a></li>
<li><a class="reference" href="mailto:edloper&#64;gradient.cis.upenn.edu">Edward Loper</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="documentation-crossreference-links">
<h2>Documentation Crossreference Links</h2>
<p>The inline markup construct '<tt class="docutils literal"><span class="pre">L{</span></tt><em>text&lt;object&gt;</em><tt class="docutils literal"><span class="pre">}</span></tt>' is used to create
links to the documentation for other Python objects. '<em>text</em>' is the text that
should be displayed for the link, and '<em>object</em>' is the name of the Python
object that should be linked to. If you wish to use the name of the Python
object as the text for the link, you can simply write <tt class="docutils literal"><span class="pre">L{</span></tt><em>object</em>}``.
Whitespace within object names is ignored. In particular, object names may be
split over multiple lines. The following example illustrates how documentation
crossreference links can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    - L{x_transform}</span>
<span class="py-string">    - L{search&lt;re.search&gt;}</span>
<span class="py-string">    - L{The I{x-transform} function</span>
<span class="py-string">    &lt;x_transform&gt;}</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><ul class="first last simple">
<li><a class="reference" href="http://www.example.com">x_transform</a></li>
<li><a class="reference" href="http://www.example.com">search</a></li>
<li><a class="reference" href="http://www.example.com">The x-transform function</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>In order to find the object that corresponds to a given name, epydoc checks the
following locations, in order:</p>
<ol class="arabic simple">
<li>If the link is made from a class or method docstring, then epydoc checks for
a method, instance variable, or class variable with the given name.</li>
<li>Next, epydoc looks for an object with the given name in the current module.</li>
<li>Epydoc then tries to import the given name as a module. If the current
module is contained in a package, then epydoc will also try importing the
given name from all packages containing the current module.</li>
<li>Epydoc then tries to divide the given name into a module name and an
object name, and to import the object from the module. If the current module
is contained in a package, then epydoc will also try importing the module
name from all packages containing the current module.</li>
<li>Finally, epydoc looks for a class name in any module with the given name.
This is only returned if there is a single class with such name.</li>
</ol>
<p>If no object is found that corresponds with the given name, then epydoc
issues a warning.</p>
</div>
<div class="section" id="indexed-terms">
<h2>Indexed Terms</h2>
<p>Epydoc automatically creates an index of term definitions for the API
documentation. The inline markup construct '<tt class="docutils literal"><span class="pre">X{...}</span></tt>' is used to mark terms
for inclusion in the index. The term itself will be italicized; and a link will
be created from the index page to the location of the term in the text. The
following example illustrates how index terms can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    An X{index term} is a term that</span>
<span class="py-string">    should be included in the index.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">An <em>index term</em> is a term that should be included in the index.</p>
<blockquote class="last">
<table border="1" class="docutils">
<colgroup>
<col width="46%" />
<col width="54%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head" colspan="2">Index</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>index term</td>
<td><em>example</em></td>
</tr>
<tr><td>x intercept</td>
<td><em>x_intercept</em></td>
</tr>
<tr><td>y intercept</td>
<td><em>x_intercept</em></td>
</tr>
</tbody>
</table>
</blockquote>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="symbols">
<h2>Symbols</h2>
<p>Symbols are used to insert special characters in your documentation. A symbol
has the form '<tt class="docutils literal"><span class="pre">S{code}</span></tt>', where code is a symbol code that specifies what
character should be produced. The following example illustrates how symbols can
be used to generate special characters:</p>
<!-- This data file has been placed in the public domain. -->
<!-- Derived from the Unicode character mappings available from
<http://www.w3.org/2003/entities/xml/>.
Processed by unicode2rstsubs.py, part of Docutils:
<http://docutils.sourceforge.net>. -->
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    Symbols can be used in equations:</span>

<span class="py-string">      - S{sum}S{alpha}/x S{&lt;=} S{beta}</span>

<span class="py-string">    S{&lt;-} and S{larr} both give left</span>
<span class="py-string">    arrows.  Some other arrows are</span>
<span class="py-string">    S{rarr}, S{uarr}, and S{darr}.</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">Symbols can be used in equations:</p>
<ul class="simple">
<li>&#8721; &#945;/<em>x</em> &#8804; &#946;</li>
</ul>
<p class="last">&#8592; and &#8592; both give left
arrows.  Some other arrows are
&#8594;, &#8593;, and &#8595;.</p>
</td>
</tr>
</tbody>
</table>
<p>Although symbols can be quite useful, you should keep in mind that they can
make it harder to read your docstring in plaintext. In general, symbols should
be used sparingly. For a complete list of the symbols that are currently
supported, see the reference documentation for <a class="reference" href="http://epydoc.sourceforge.net/api/epydoc.markup.epytext-module.html#SYMBOLS"><tt class="docutils literal"><span class="pre">epytext.SYMBOLS</span></tt></a>.</p>
</div>
<div class="section" id="escaping">
<h2>Escaping</h2>
<p>Escaping is used to write text that would otherwise be interpreted as epytext
markup. Epytext was carefully constructed to minimize the need for this type
of escaping; but sometimes, it is unavoidable. Escaped text has the form
'<tt class="docutils literal"><span class="pre">E{</span></tt><em>code</em><tt class="docutils literal"><span class="pre">}</span></tt>', where code is an escape code that specifies what
character should be produced. If the escape code is a single character (other
than '<tt class="docutils literal"><span class="pre">{</span></tt>' or '<tt class="docutils literal"><span class="pre">}</span></tt>'), then that character is produced. For example, to
begin a paragraph with a dash (which would normally signal a list item), write
'<tt class="docutils literal"><span class="pre">E{-}</span></tt>'. In addition, two special escape codes are defined: '<tt class="docutils literal"><span class="pre">E{lb}</span></tt>'
produces a left curly brace ('<tt class="docutils literal"><span class="pre">{</span></tt>'); and '<tt class="docutils literal"><span class="pre">E{rb}</span></tt>' produces a right curly
brace ('<tt class="docutils literal"><span class="pre">}</span></tt>'). The following example illustrates how escaping can be used:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    This paragraph ends with two</span>
<span class="py-string">    colons, but does not introduce</span>
<span class="py-string">    a literal blockE{:}E{:}</span>

<span class="py-string">    E{-} This is not a list item.</span>

<span class="py-string">    Escapes can be used to write</span>
<span class="py-string">    unmatched curly braces:</span>
<span class="py-string">    E{rb}E{lb}</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td><p class="first">This paragraph ends with two colons, but does not introduce a literal
block::</p>
<p>- This is not a list item.</p>
<p class="last">Escapes can be used to write unmatched curly braces: }{</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="graphs">
<h2>Graphs</h2>
<p>The inline markup construct '<tt class="docutils literal"><span class="pre">G{</span></tt><em>graphtype args...</em><tt class="docutils literal"><span class="pre">}</span></tt>' is used to
insert automatically generated graphs. The following graphs generation
constructions are currently defines:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Markup</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">G{classtree</span></tt>  <em>classes...</em><tt class="docutils literal"><span class="pre">}</span></tt></td>
<td>Display a class hierarchy for the given
class or classes (including all
superclasses &amp; subclasses). If no class
is specified, and the directive is used
in a class's docstring, then that
class's class hierarchy will be
displayed.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">G{packagetree</span></tt>  <em>modules...</em><tt class="docutils literal"><span class="pre">}</span></tt></td>
<td>Display a package hierarchy for the
given module or modules (including all
subpackages and submodules). If no
module is specified, and the directive
is used in a module's docstring, then
that module's package hierarchy will be
displayed.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">G{importgraph</span></tt>  <em>modules...</em><tt class="docutils literal"><span class="pre">}</span></tt></td>
<td>Display an import graph for the given
module or modules. If no module is
specified, and the directive is used in
a module's docstring, then that
module's import graph will be
displayed.</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">G{callgraph</span></tt>  <em>functions...</em><tt class="docutils literal"><span class="pre">}</span></tt></td>
<td>Display a call graph for the given
function or functions. If no function
is specified, and the directive is used
in a function's docstring, then that
function's call graph will be
displayed.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="characters">
<h1>Characters</h1>
<div class="section" id="valid-characters">
<h2>Valid Characters</h2>
<p>Valid characters for an epytext docstring are space (<tt class="docutils literal"><span class="pre">\040</span></tt>); newline
(<tt class="docutils literal"><span class="pre">\012</span></tt>); and any letter, digit, or punctuation, as defined by the current
locale. Control characters (<tt class="docutils literal"><span class="pre">\000</span></tt>-<tt class="docutils literal"><span class="pre">\010`</span> <span class="pre">and</span> <span class="pre">``\013</span></tt>-<tt class="docutils literal"><span class="pre">\037</span></tt>) are not
valid content characters. Tabs (<tt class="docutils literal"><span class="pre">\011</span></tt>) are expanded to spaces, using the
same algorithm used by the Python parser. Carridge-return/newline pairs
(<tt class="docutils literal"><span class="pre">\015\012</span></tt>) are converted to newlines.</p>
</div>
<div class="section" id="content-characters">
<h2>Content Characters</h2>
<p>Characters in a docstring that are not involved in markup are called <em>content characters</em>. Content characters are always displayed as-is. In particular, HTML
codes are not passed through. For example, consider the following example:</p>
<table border="1" class="docutils">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Docstring Input</th>
<th class="head">Rendered Output</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><pre class="py-doctest">
<span class="py-keyword">def</span> <span class="py-defname">example</span>():
    <span class="py-string">&quot;&quot;&quot;</span>
<span class="py-string">    &lt;B&gt;test&lt;/B&gt;</span>
<span class="py-string">    &quot;&quot;&quot;</span>
    <span class="py-comment">#[...]</span></pre>
</td>
<td>&lt;B&gt;test&lt;/B&gt;</td>
</tr>
</tbody>
</table>
<p>The docstring is rendered as <tt class="docutils literal"><span class="pre">&lt;B&gt;test&lt;/B&gt;</span></tt>, and not as the word &quot;test&quot; in
bold face.</p>
</div>
<div class="section" id="spaces-and-newlines">
<h2>Spaces and Newlines</h2>
<p>In general, spaces and newlines within docstrings are treated as soft spaces.
In other words, sequences of spaces and newlines (that do not contain a blank
line) are rendered as a single space, and words may wrapped at spaces. However,
within literal blocks and doctest blocks, spaces and newlines are preserved,
and no word-wrapping occurs; and within URL targets and documentation link
targets, whitespace is ignored.</p>
</div>
</div>
</div>
<table width="100%" class="navbox" cellpadding="1" cellspacing="0">
  <tr>
  <a class="nav" href="index.html">
    <td align="center" width="20%" class="nav">
    <a class="nav" href="index.html">
    Home</a></td></a>
  <a class="nav" href="installing.html">
    <td align="center" width="20%" class="nav">
    <a class="nav" href="installing.html">
    Installing Epydoc</a></td></a>
  <a class="nav" href="using.html">
    <td align="center" width="20%" class="nav">
    <a class="nav" href="using.html">
    Using Epydoc</a></td></a>
  <a class="nav" href="epytext.html">
    <td align="center" width="20%" class="nav">
    <a class="nav" href="epytext.html">
    Epytext</a></td></a>
  <td align="center" width="20%" class="nav">
    
    <A href="http://sourceforge.net/projects/epydoc"> 
    <IMG src="sflogo.png" 
    width="88" height="26" border="0" alt="SourceForge"
    align="top"/></A></td>
    </tr>
</table>
</body>
</html>
